home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ CDEV ƒ / UScanCDEV.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-24  |  2.6 KB  |  68 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    UScanCDEV.h (MPW 3.2)
  3.  *    Copyright ©1991 David Kreindler.  All rights reserved.
  4.  *    
  5.  *    KNOWN BUGS AND SHORTCOMINGS:
  6.  *        TScanCDEV::DoUpdate() contains a hard-coded literal string; it should be stored as a resource
  7.  */
  8.  
  9. #ifndef __USCANCDEV__
  10. #define __USCANCDEV__
  11.  
  12. #ifndef __FILES__
  13. #include <Files.h>
  14. #endif
  15.  
  16. #ifndef __UCONTROLPANEL__
  17. #include <UControlPanel.h>
  18. #endif
  19.  
  20. class TScanCDEV: public TControlPanel {
  21.     public:
  22.         TScanCDEV(DialogPtr, short numItems);
  23.         void DoHit(short, EventRecord *, long *cdevValue);                                    // override
  24.         void DoUpdate(long *cdevValue);                                                        // override
  25.     protected:
  26.         virtual void DoDirectory(const CInfoPBRec &);                                        // called once for each subdirectory entry in the catalog
  27.         virtual void DoFile(const CInfoPBRec &);                                            // called once for each file entry in the catalog
  28.         virtual void ScanVolume();                                                            // scans the startup volume
  29.         virtual void ShowStatus(ConstStr255Param);
  30.     private:
  31.         void ScanDirectory(long);                                                            // scans the given directory; calls itself recursively to scan subvolumes
  32.     private:
  33.         CInfoPBRec fCatalogInfo;                                                            // used by ScanVolume() and ScanDirectory() as the parameter block for file system calls; this could be declared static, since we are guaranteed no more than one instantiation at a time
  34.         Str31 fDirEntryName;                                                                // what fCatalogInfo.hFileInfo.ioNamePtr will point to; this could be declared static, since we are guaranteed no more than one instantiation at a time
  35.         static const Rect kDirectoryRect;                                                    // where in the control panel we draw the subdirectory’s name
  36.         static const Rect kFileRect;                                                        // where we draw the file’s name
  37.         static const Rect kStatusRect;                                                        // where we draw our status information
  38. };
  39.  
  40. void TextBox(const Rect &, ConstStr255Param, short just = teJustLeft);                        // overload (this is here because this is example code; it should be in a library)
  41.  
  42. /* —————————————————————————————————— inline definitions —————————————————————————————————— */
  43.  
  44. inline void TextBox(const Rect &rect, ConstStr255Param string, short just) {
  45.     TextBox(string + 1, *string, &rect, just);
  46. }
  47.  
  48. inline void TScanCDEV::DoDirectory(const CInfoPBRec &catInfo) {
  49.     TextBox(kDirectoryRect, catInfo.hFileInfo.ioNamePtr);
  50. }
  51.  
  52. inline void TScanCDEV::DoFile(const CInfoPBRec &catInfo) {
  53.     TextBox(kFileRect, catInfo.hFileInfo.ioNamePtr);
  54. }
  55.  
  56. inline void TScanCDEV::ShowStatus(ConstStr255Param status) {
  57.     TextBox(kStatusRect, status);
  58. }
  59.  
  60. inline void TScanCDEV::DoUpdate(long *) {
  61.     ShowStatus("\pIdle");                                                                    // !!!
  62. }
  63.  
  64. inline TScanCDEV::TScanCDEV(DialogPtr theDialog, short numItems):
  65.     TControlPanel(theDialog, numItems) {
  66. }
  67.  
  68. #endif